<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id = 'btn'>点击</button>
    <script>
        const btn = document.getElementById('btn')
        function clickFn(){
            console.log('点击了')
        }
        btn.addEventListener('click',throttle(clickFn,3000))
        function throttle(fn,delay){
            let oldTime = Date.now()
            return function(...arg){
                let newTime = Date.now()
                if(newTime - oldTime > delay){
                    fn.call(this,...arg)
                    oldTime = Date.now()
                }
            }
        }
    </script>
</body>
</html>